package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {

	// default 返回一个默认参数
	r := gin.Default()
	r.GET("user/search", func(c *gin.Context) {

		username := c.DefaultQuery("username", "小王子")
		address := c.Query("address")
		// 输出json结果给调用方
		c.JSON(http.StatusOK, gin.H{
			"message":  "ok",
			"username": username,
			"address":  address,
		})
	})

	r.Run()

}
